package jasima.engine.simulate.execute;

import jasima.engine.models.input.SimScheme;
import jasima.engine.models.simulate.ExecScheme;
import jasima.engine.models.simulate.shop.ExecItem;
import lombok.Data;
import org.springframework.beans.BeanUtils;

@Data
public class SimData extends SimScheme {
    private ShopExector shop;
    private ExecScheme execScheme;

    public SimData(SimScheme simScheme) {
        shop = new ShopExector(this);
        execScheme = new ExecScheme();
        BeanUtils.copyProperties(simScheme, execScheme);
        execScheme.setInput(simScheme);

        initData();
    }

    protected void initData() {
        this.getExecScheme().getShop().getItems()
                .forEach(item -> {
                    item.getRoutes().forEach(route -> {
                        route.setItem(item);
                        route.getOperations().forEach(op -> {
                            op.setRoute(route);
                        });
                    });
                });
    }
}
